<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="com.store.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@include file="../global_var.jsp"%>
<%@page import="java.io.File"%>
<%@include file="../check_login.jsp"%>

<%

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
ContractMgr contractMgr = new ContractMgr();
String conid = ParamUtils.getParameter(request,"conid","0");
int contype = ParamUtils.getIntParameter(request,"contype",1);
String engineer = ParamUtils.getParameter(request,"engineer","");
String assigntime          = ParamUtils.getParameter(request,"assigntime",TSSDate.shortDate());
String cmd = ParamUtils.getParameter(request,"cmd","");
Contract contract = contractMgr.get(conid) ;
String strErr = "";
	if (contract == null || contract.getId().trim().equals("")) strErr = "此合同信息不存在!";
User just_user = (User)session.getAttribute("LoginUser");

String power_enable_id = "10009";
String power1_enable_id ="10109";
if(contract.getContype()==1){
if (!just_user.hasPower(power_enable_id)) {
	out.println(strNoPowerInfo); 
	return;
}
}
if(contract.getContype()==2){
		if (!just_user.hasPower(power1_enable_id)) {
			out.println(strNoPowerInfo); 
			return;
		}
}
	

if (cmd.trim().equals("")) {
engineer=contract.getEngineer();
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
<title>My JSP 'techcontract_add.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link href="style/main.css" rel="stylesheet" type="text/css">
	<script language="javascript" src="js/common.js"></script>
   <script language="javascript" >
  function clk_goback() {
var oForm=document.operatorForm;
	if(oForm.contype.value==1)location.href="../incontract_mgt/incon_list.jsp";
if(oForm.contype.value ==2)location.href="../outcontract_mgt/outcon_list.jsp";
}
  function clk_submit() {
	var oForm = document.operatorForm;
	oForm.cmd.value = "insert";
	return true;
 }
 function clk_insert_engineer(conid) {
	var str = "incontract_mgt/insert_engineer.jsp?conid=" + conid ;
	var r = window.showModalDialog('../selectFrm.htm',str,'dialogHeight: 300px;dialogWidth: 400px;center:yes;dialogHide:no;status:no;help: no');
   	if(r != null)
   	{
   		ifrmActiveArea.location.href = "../incontract_mgt/engineer_modi_refresh.jsp?conid=" + conid;
   		//parent.mainFrm.location.href = "project_show.jsp?prjid="+prjid;
   	}
}
function clk_delete_engineer(conid,taskid,engid) {
if (!confirm("确定要删除此条记录吗？"))
		return;
		
if(taskid!=0){ 
alert("此工程师已经建立了工单您不能删除");
	return;
}		
	ifrmActiveArea.location.href ="../incontract_mgt/engineer_modi_refresh.jsp?taskid="+taskid+"&conid="+conid+"&engid="+engid+"&cmd=delete";
}
function clk_task_view(taskid){
var oForm = document.operatorForm;
	var ret = window.showModalDialog('../selectFrm.htm','task_mgt/task_view.jsp?taskid='+taskid,'dialogHeight: 500px;dialogWidth: 800px; center: yes; status:no;help: no');



}
</script>
</head>
<body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td >
      <form name="operatorForm" method="post" onSubmit="return clk_goback();">

      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="100" align="center" valign="top" style="padding-top:10px;padding-bottom:10px;">
            <table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
			
			 <tr>
                <td height="24" colspan="7" bgcolor="#EDEDF0" style="padding-left:10px;">
                提示：<font color="red">*</font> 号为必填项，请您认真填写                </td>
              </tr>
               <%if (!strErr.trim().equals("")) {%>
              <tr> 
                <td height="24" colspan="7" bgcolor="#D7D7DB" style="padding-left:10px;">
                  错误提示：
                 
                  <font color=red><%=strErr%></font>                </td>
              </tr>
              <%}%>
              
              <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>用户信息</strong></font>  </td>
              </tr>
               <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">合同类型：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			   <%
			   String contype_name="内部合同";
			   if(contract.getContype()==2) contype_name="外部合同";
			   %>
			    <%=contype_name%></td>
			    </tr>
		
		
             <tr> 
                <td width="17%" height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">所在区域：</td>
                <td bgcolor="#EDEDF0" style="padding-left:5px;">
                  <%=contract.getArea()%>
                  
               </td>
              </tr>
              <tr> 
                <td width="17%" height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">合同编号：</td>
                <td width="83%" colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
                <%=contract.getConid()%>
                 
                  &nbsp;&nbsp;</td>
              </tr>
			  
              <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;"> 服务合同号：</td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;"> 
              <%=contract.getServiceid()%>
                 
                 </td>
              </tr>
              <tr>
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">客户名称：</td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
         <%=contract.getCustomer()%>
                
                </td>
              </tr>
  
                 <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >联系人：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   
                   
                 <%=contract.getLinkman()%></td>
                 </tr>
                 <tr>
                   <td height="23" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >联系电话：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   
                 <%=contract.getPhone()%></td>
                 </tr>
                 <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >销售员：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                  <%=contract.getSale_name()%></td>
                 </tr>
               
                 <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >合同开始执行时间：</td>
                <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                <span id="htmlSaleTime"> 
                  	 <%=contract.getBegindate()%>          </td>
              </tr>
             
               <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >合同到期时间：</td>
                <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
              <%=contract.getEnddate()%>           </td>
              </tr>
              
			  <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">合同服务等级：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <%
			    
			    String servicelevel="";
                 if (contract.getServicelevel()==1) servicelevel="初级";
                   if (contract.getServicelevel()==2) servicelevel="中级";
                     if (contract.getServicelevel()==3) servicelevel="高级";
			    %>
					 <%=servicelevel%>	   
					 
					 
					 
					  </td>
			    </tr>
			  <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">合同描述：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <%=contract.getContractdesc()%></td>
			    </tr>
			  
			 
			    <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">厂商名称：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <%=contract.getCom_name()%></td>
			    </tr>
			    <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">项目经理：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <%=contract.getTechmanager_name()%></td>
			    </tr>
			   
			       <%if(! contract.getEngineer().trim().equals("")){%>
			  <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">分配工程师时间：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <%=contract.getAssigntime()%></td>
			    </tr>
			  <%}%>
              <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">
			   合同分析报告：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    <%
						String savePath="upload/analyreport";
						String fileName=contract.getAnalyreport();
						File fileSave = new File(pageContext.getServletContext().getRealPath(savePath + "/" + fileName));
			if (fileSave.exists()) {
						%>
			    	<a href="do_download.jsp?filename=upload/analyreport/<%=contract.getAnalyreport()%>" > <%=contract.getAnalyreport()%></a>
			    	
			    	<%}else{%>
					此附件已被删除
					<%}%>
			    	</td>
			    </tr>
			    <tr>
			    <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">
			    技术支援单：</td>
			    <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
			    	<%
						 savePath="upload/techsupport";
						 fileName=contract.getTechsupport();
						 fileSave = new File(pageContext.getServletContext().getRealPath(savePath + "/" + fileName));
			if (fileSave.exists()) {
						%>
			    	<a href="do_download.jsp?filename=upload/techsupport/<%=contract.getTechsupport()%>" > <%=contract.getTechsupport()%></a>
			    	
			    	<%}else{%>
					此附件已被删除
					<%}%>
			    	</td>
			    </tr>
                <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">
                合同附件文件：</td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
              	<%
						 savePath="upload/contractfile";
						 fileName=contract.getContractlile();
						 fileSave = new File(pageContext.getServletContext().getRealPath(savePath + "/" + fileName));
			if (fileSave.exists()) {
						%>
              	
              	<a href="do_download.jsp?filename=upload/contractfile/<%=contract.getContractlile()%>" > <%=contract.getContractlile()%></a>
					<%}else{%>
					此附件已被删除
					<%}%>
				</td>
              </tr>
            
                <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>采购产品明细</strong></font> &nbsp;&nbsp;
                   </td>
              </tr>
                <tr>
                  <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;"><p>培训时间：</p>   
				 </td>
                  <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
				  
				  从<%=contract.getTechbegindate()%>
 							至 	
							 <%=contract.getTechenddate()%>
				  
				  &nbsp;</td>
                </tr>
                <tr>
                  <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">专业化服务时间：</td>
                  <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
				  
				  从<%=contract.getSevbegindate()%>
 							至 	

                 <%=contract.getSevenddate()%>
				  
				  &nbsp;</td>
                </tr>
               
			   <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>合同费用</strong></font>&nbsp;&nbsp;                   </td>
              </tr>
			    <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >初次安装费：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
             <%=FormatNum.formatCurrencycn(contract.getFifee())%></td>
                </tr>
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >(1-3年)现场维护：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			     <%=FormatNum.formatCurrencycn(contract.getMfee())%></td>
		        </tr>
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >现场维护年限：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			    <%=contract.getMyear()%> 年</td>
		        </tr>
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >备件成本：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			   <%=FormatNum.formatCurrencycn(contract.getSpartfee())%></td>
		        </tr>
			    <tr>
			      <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >外部人员技术成本：</td>
			      <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
			     <%=FormatNum.formatCurrencycn(contract.getOutefee())%></td>
		        </tr>
		         <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>工程师信息</strong></font> &nbsp;&nbsp;
                  <input type="button" name="btn" value="添加工程师" class="inputButton" onclick="clk_insert_engineer('<%=contract.getConid()%>')">
                
                </td>
              </tr>
              <tr align="center" valign="top" bgcolor="#EDEDF0"> 
                <td height="20" colspan="7" id="htmlDeviceInfo"> 
                
                  <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#EDEDF0" id="tbDeviceDetail">
                    <tr align="center" bgcolor="#D7D7DB"> 
                     <td width="18%" height="23" bgcolor="#D7D7DB"> 工程师姓名</td>
                      <td width="13%">工程师E-mail</td>
                      <td width="22%">工程师电话</td>
                      <td width="13%">工单状态</td>
                       <td width="9%">详情</td>
                       <td width="9%">操作</td>
                    </tr>
                <%
                   List list = contract.getListEngs();
                    if (list != null && list.size() > 0) {
                    	for(int i=0;i<list.size();i++) {
                    		Techconeng techEng = (Techconeng)list.get(i);
                    		
                    %>
                    <tr align="center" bgcolor="#FFFFFF">
                      <td height="24"><%=techEng.getEng_name()%></td>
                      <td><%=techEng.getUser().getEmail()%></td>
                      <td><%=techEng.getUser().getPhone()%></td>
                      <td> <%=techEng.getTaskStatus_name()%> </td>
                   <td>
                       <% if(techEng.getTaskid()!=0){%>
                        <span onclick="clk_task_view('<%=techEng.getTaskid()%>');"
							style="cursor:hand;text-decoration: underline;">查看</span>
							<%}%>
							</td>
                    	
                 <td><img src="images/dustbin_tag.gif" title="删除信息" style="cursor:hand;" onclick="clk_delete_engineer('<%=techEng.getConid()%>','<%=techEng.getTaskid()%>','<%=techEng.getEngid()%>')"></td>
            </tr>
                    <%}}%>
                  </table>
                </td>
              </tr>
              <tr> 
                <td bgcolor="#EDEDF0" colspan="7" align="center">
               
              
                  <input type="button" onclick="clk_goback();" name="btn" value="返　回" class="inputButton"> 
                   <input type="hidden"  name="cmd" value="" > 
                
                   <input type="hidden"  name="contype" value="<%=contype%>" > 
                  </td>
              </tr>
            </table>
          </td>
        </tr>
       
      </table>
      </form>
    </td>
  </tr>
</table>
<iframe id="ifrmActiveArea" name="ifrmActiveArea" frameborder="0" width="1" height="1" scrolling="no"></iframe>



</body>


</html>
